# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=ratbag
pkgver=0.17
pkgrel=1
pkgdesc="DBus daemon to configure input devices, mainly gaming mice"
url="https://github.com/libratbag/libratbag"
arch="all"
license="MIT"
depends="dbus"
makedepends="
	elogind-dev
	eudev-dev
	glib-dev
	json-glib-dev
	libevdev-dev
	libunistring-dev
	meson
	py3-gobject3-dev
	python3-dev
	swig
"
checkdepends="check-dev py3-gobject3 py3-evdev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-tools:_tools"
source="$pkgname-$pkgver.tar.gz::https://github.com/libratbag/libratbag/archive/refs/tags/v$pkgver.tar.gz
	python-3.12.patch
	gcc14.patch"
builddir="$srcdir/libratbag-$pkgver"

build() {
	abuild-meson \
		-Db_lto=true \
		-Dsystemd=false \
		-Dlogind-provider=elogind \
		-Dtests="$(want_check && echo true || echo false)" \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

_tools() {
	pkgdesc="ratbag cli tools"
	depends="python3 py3-evdev py3-gobject3"

	amove usr/bin/ratbagctl
	amove usr/bin/lur-command
}

sha512sums="
80ab5c895d83e28b6b6adcd0669854944d7932ef037c8d64b923a7362399e861475e9d81c5ee2cf814f654d7796b00a81314cc177f34e13c8684d525974068c8  ratbag-0.17.tar.gz
1e2ebd5c49de257416b5dd2f578ed2ec6060c9067a9e050406ea81103b8294a737d1885186d6d074837216bc608b93485a5c9a26a5604e0f278a58d71ce0c655  python-3.12.patch
5c29040f2c9febe2cb3a7fccffe12d0a97ac4a4dd27fcae9c34a8244e570960ee90ba2bbcd024be7dc4c9bcd61544e9e45257ff4e1eb6c17af1bffa671faef42  gcc14.patch
"
